#include <stdio.h>

#define N_MAX 7000

typedef unsigned char bool_t;


void
__remove_elem(int index, int* where, int size)
{
	register short i;

	for (i = index ; i < size - 1 ; ++i) {
		where[i] = where[i+1];
	}
	where[size-1] = 0;
}



void
remove_elem(int index, int* where, int size)
{
	int tmp;

	tmp          = where[index];
	where[index] = where[--size];
	where[size]  = tmp;
}



int
lookup_elem_slow(int what, int* where, int n)
{
	register short i;

	for (i = 0; i < n; ++i) {
		if (where[i] == what)
			return i;
	}
	return -1;
}



bool_t
is_permutation(int* old, int* new_, int size)
{
	register short i, j;

	for (i = 0 ; i < size ; ++i) {
		if (j = lookup_elem_slow(new_[i], old, size), j != -1) {
			remove_elem(i--, new_, size);
			remove_elem(j, old, size--);
		}
	}
	if (size > 0)
		return false;
	else
		return true;
}



int
main(void)
{
	int n, orig[N_MAX], new_[N_MAX];
	int i = 0;
	freopen("arrays.in", "rt", stdin);
	freopen("arrays.out", "w", stdout);

	scanf("%d", &n);
	while (i<n)
		scanf("%d", &orig[i++]);
	i = 0;
	while (i<n)
		scanf("%d", &new_[i++]);

	printf("%s\n", is_permutation(orig, new_, n) ? "YES" : "NO");
	return 0;
}
